home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 1 / Mac Magazin and MacEasy Magazine CD - Issue 01.iso / Sharewarebibliothek / Powermac / C64 / SOURCE / Instructions.h < prev    next >
Text File  |  1994-06-06  |  4KB  |  143 lines

  1. #define FlagsNZ(z)\
  2.     flags &=~(ZER+NEG); if (z==0) flags|=ZER; else flags |=z&128
  3.  
  4. #define ORA(x) a|=ByteAt(x()); FlagsNZ(a)
  5. #define ASL(x) \
  6.     register word addr;\
  7.     register byte tbyte;\
  8.     addr = x();\
  9.     tbyte = ByteAt(addr);\
  10.     flags &=~(CAR+NEG+ZER);\
  11.     if (tbyte&128) flags |= CAR;\
  12.     if (tbyte=tbyte<<1) flags |=tbyte&128; else flags |=ZER;\
  13.     RAM[addr] = tbyte
  14. #define LSR(x) \
  15.     register word addr;\
  16.     register byte tbyte;\
  17.     addr=x();\
  18.     tbyte=ByteAt(addr);\
  19.     flags &=~(CAR+NEG+ZER);\
  20.     flags |=tbyte&1;\
  21.     if (tbyte=tbyte>>1); else flags |=ZER;\
  22.     RAM[addr]=tbyte
  23. #define BCL(x) \
  24.     register byte tbyte;\
  25.     if (flags&x) pc++; \
  26.     else {\
  27.         tbyte=ImmediateByte();\
  28.         pc++;\
  29.         if (tbyte&128) {\
  30.             pc-=(tbyte^255)+1;\
  31.             return; }\
  32.         pc +=tbyte; }
  33. #define BST(x) \
  34.     register byte tbyte;\
  35.     if (flags&x) {\
  36.         tbyte=ImmediateByte();\
  37.         pc++;\
  38.         if (tbyte&128) {\
  39.             pc-=(tbyte^255)+1;\
  40.             return; }\
  41.         pc +=tbyte; }\
  42.     else pc++;
  43. #define CLR(x) flags &=~x; return
  44. #define SET(x) flags |= x; return
  45. #define AND(x) a &= ByteAt(x()); FlagsNZ(a)
  46. #define BIT(x) \
  47.     register byte tbyte;\
  48.     tbyte=ByteAt(x());\
  49.     flags &=~(ZER+NEG+OVF);\
  50.     if ((a&tbyte)==0) flags |=ZER;\
  51.     flags |=tbyte&(128+64)
  52. #define ROL(x) \
  53.     register word addr;\
  54.     register byte tbyte;\
  55.     addr=x();\
  56.     tbyte=ByteAt(addr);\
  57.     if (flags&CAR) {\
  58.         if (tbyte&128);\
  59.         else flags &=~CAR;\
  60.         tbyte=(tbyte<<1)|1; }\
  61.     else {\
  62.         if (tbyte&128) flags|=CAR;\
  63.         tbyte=tbyte<<1; }\
  64.     FlagsNZ(tbyte);\
  65.     RAM[addr]=tbyte
  66. #define EOR(x)     a^=ByteAt(x());FlagsNZ(a)
  67. #define ADC(x) \
  68.     register word data;\
  69.     data=ByteAt(x());\
  70.     if (flags&DEC) {\
  71.         data = bcd2dec[data]+bcd2dec[a]+((flags&CAR)?1:0);\
  72.         flags &= ~(CAR+OVF+NEG+ZER);\
  73.         if (data>99) {flags|=CAR+OVF;data -=100;}\
  74.         if (data==0) flags|=ZER; else flags |=data&128;\
  75.         a=dec2bcd[data];}\
  76.     else {\
  77.         data += a+((flags&CAR)?1:0);\
  78.         flags &= ~(CAR+OVF+NEG+ZER);\
  79.         if (data>255) {flags|=OVF+CAR; data &=255;}\
  80.         if (data==0) flags|=ZER; else flags |=data&128;\
  81.         a=data;}
  82. #define ROR(x) \
  83.     register word addr;\
  84.     register byte tbyte;\
  85.     addr=x(); tbyte=ByteAt(addr);\
  86.     if(flags&CAR){if(tbyte&1); else flags&=~CAR;tbyte=(tbyte>>1)|128;}\
  87.     else{if(tbyte&1) flags|=CAR;tbyte=tbyte>>1;}\
  88.     FlagsNZ(tbyte); RAM[addr]=tbyte
  89. #define STA(x) RAM[x()]=a
  90. #define STY(x) RAM[x()]=y
  91. #define STX(y) RAM[y()]=x
  92. #define CPY(x) \
  93.     register byte tbyte;\
  94.     tbyte=ByteAt(x()); flags &=~(CAR+ZER+NEG);\
  95.     if (y==tbyte) flags |=CAR+ZER;\
  96.     else if (y>tbyte) flags |=CAR;\
  97.         else flags |=NEG
  98. #define CPX(y) \
  99.     register byte tbyte;\
  100.     tbyte=ByteAt(y()); flags &=~(CAR+ZER+NEG);\
  101.     if (x==tbyte) flags |=CAR+ZER;\
  102.     else if (x>tbyte) flags |=CAR;\
  103.         else flags |=NEG
  104. #define CMP(x) \
  105.     register byte tbyte;\
  106.     tbyte=ByteAt(x()); flags &=~(CAR+ZER+NEG);\
  107.     if (a==tbyte) flags |=CAR+ZER;\
  108.     else if (a>tbyte) flags |=CAR;\
  109.         else flags |=NEG
  110. #define SBC(x) \
  111.     register int data;\
  112.     data=ByteAt(x());\
  113.     if (flags&DEC) {\
  114.         data = bcd2dec[a]-bcd2dec[data]-((flags&CAR)?0:1);\
  115.         flags &= ~(CAR+ZER+NEG+OVF);\
  116.         if (data==0) flags |=ZER+CAR;\
  117.         else if (data>0) flags |=CAR;\
  118.             else {flags|=NEG; data +=100;}\
  119.         a=dec2bcd[data];}\
  120.     else {\
  121.         data = a-data-((flags&CAR)?0:1);\
  122.         flags &=~(CAR+ZER+OVF+NEG);\
  123.         if (data==0) flags |=ZER+CAR;\
  124.         else if (data>0) flags |=CAR;\
  125.             else flags|=OVF;\
  126.         flags |=data&128;\
  127.         a=data&255;}
  128. #define DECR(x) \
  129.     register word addr; register byte tbyte;\
  130.     addr=x(); tbyte=ByteAt(addr);\
  131.     flags &=~(ZER+NEG);\
  132.     if (--tbyte) flags |=tbyte&128; else flags|=ZER;\
  133.     RAM[addr]=tbyte
  134. #define INCR(x) \
  135.     register word addr; register byte tbyte;\
  136.     addr=x(); tbyte=ByteAt(addr);\
  137.     flags &=~(ZER+NEG);\
  138.     if (++tbyte) flags |=tbyte&128; else flags|=ZER;\
  139.     RAM[addr]=tbyte
  140. #define LDA(x) a=ByteAt(x()); FlagsNZ(a)
  141. #define LDY(x) y=ByteAt(x()); FlagsNZ(y)
  142. #define LDX(y) x=ByteAt(y()); FlagsNZ(x)
  143.